# To be superceded by common grid generation for both bands and qk
# Grid generation for the bandstructure code.
import numpy as np

def inputparsing():

    from optparse import OptionParser

    parser = OptionParser()

    parser.add_option("--nkx",  action="store",type="int",  default="20", help="[%default]")
    parser.add_option("--nky",  action="store",type="int",  default="20", help="[%default]")
    parser.add_option("--maxkx",action="store",type="float",default="0.1",help="[%default]")
    parser.add_option("--maxky",action="store",type="float",default="0.1",help="[%default]")
    parser.add_option("--zp",   action="store",type="float",default="0",  help="[%default]")
    op,args=parser.parse_args()

    return op

if __name__=="__main__":

    op=inputparsing()
    zp = op.zp;
    x=np.linspace(-op.maxkx,op.maxkx,op.nkx)
    y=np.linspace(-op.maxky,op.maxky,op.nky)

    ix = np.arange(0,x.shape[0])
    iy = np.arange(0,y.shape[0])
    ix,iy = np.meshgrid(ix,iy)
    ix = ix.flatten()
    iy = iy.flatten()

    xx,yy=np.meshgrid(x,y)

    xx = xx.flatten()
    yy = yy.flatten()


    print xx.shape, ix.shape,iy.shape
    k = np.vstack((xx,yy,0*xx + zp,ix,iy)).T
    
    np.savetxt("kfile.dat",k)
    
    print "k shape ",k.shape
